package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbPlaces;
import com.ruoyi.wb.service.IWbPlacesService;
import com.ruoyi.wb.vo.WbPlacesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 地理位置
 * 
 * @author ruoyi
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/wb/places")
public class WbPlacesController extends BaseController
{
    @Autowired
    private IWbPlacesService wbPlacesService;

    /**
     * 查询地理位置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbPlaces wbPlaces)
    {
        List<WbPlaces> list = wbPlacesService.selectWbPlacesList(wbPlaces);
        return getDataTable(list);
    }


    /**
     * 查询所有地理位置列表
     */
    @GetMapping("/getPlaces")
    public AjaxResult getPlaces(){
        List<WbPlacesVo> list = wbPlacesService.getPlaces();
        return success(list);
    }



    /**
     * 导出地理位置列表
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbPlaces wbPlaces)
    {
        List<WbPlaces> list = wbPlacesService.selectWbPlacesList(wbPlaces);
        ExcelUtil<WbPlaces> util = new ExcelUtil<WbPlaces>(WbPlaces.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取地理位置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(wbPlacesService.selectWbPlacesById(id));
    }

    /**
     * 新增地理位置
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbPlaces wbPlaces)
    {
        return toAjax(wbPlacesService.insertWbPlaces(wbPlaces));
    }

    /**
     * 修改地理位置
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbPlaces wbPlaces)
    {
        return toAjax(wbPlacesService.updateWbPlaces(wbPlaces));
    }

    /**
     * 删除地理位置
     */
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wbPlacesService.deleteWbPlacesByIds(ids));
    }



}
